<?php
function nextsong(){
	$link = mysql_connect('localhost','root','')or die (mysql_error());
	mysql_select_db('audio')or die (mysql_error());
	$query= "select count(*) from cola";
	$result = mysql_query($query) or die (mysql_error());
	$prt=mysql_fetch_assoc($result)or die (mysql_error());
	if($prt['count(*)']==0){
		$query = "select count(*) from audio AS count";
		$result = mysql_query($query) or die (mysql_error());
		$prt = mysql_fetch_assoc($result)or die (mysql_error());
		$limit = (integer) $prt['count(*)'];
		$id = rand(1,$limit);
		$query="Select * from audio where id=$id";
		$result = mysql_query($query) or die (mysql_error());
		$prt = mysql_fetch_assoc($result)or die (mysql_error());
	}
	else{
		$query="Select * from cola c,audio a WHERE c.id=a.id";
		$result = mysql_query($query) or die (mysql_error());
		$prt = mysql_fetch_assoc($result)or die (mysql_error());
		$id=$prt['id'];
		$query ="delete from cola where id=$id";
		$result = mysql_query($query) or die (mysql_error());
	}
	return $prt;
}
function queuelist(){
	$link = mysql_connect('localhost','root','')or die (mysql_error());;
	mysql_select_db('audio')or die (mysql_error());;
	$query="Select * from cola c,audio a where a.id=c.id";
	$result = mysql_query($query) or die (mysql_error());
	return $result;
}